/**
 * This is a generated class and is not intended for modfication.  To customize behavior
 * of this value object you may modify the generated sub-class of this class - Table.as.
 */

package valueObjects
{
import com.adobe.fiber.services.IFiberManagingService;
import com.adobe.fiber.valueobjects.IValueObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.collections.ArrayCollection;
import mx.events.PropertyChangeEvent;
import valueObjects.Round;
import valueObjects.Seat;

import flash.net.registerClassAlias;
import flash.net.getClassByAlias;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;

use namespace model_internal;

[ExcludeClass]
public class _Super_Table extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
{
    model_internal static function initRemoteClassAliasSingle(cz:Class) : void 
    {
        try 
        {
            if (flash.net.getClassByAlias("engine.Table") == null)
            {
                flash.net.registerClassAlias("engine.Table", cz);
            } 
        }
        catch (e:Error) 
        {
            flash.net.registerClassAlias("engine.Table", cz); 
        }
    }   
     
    model_internal static function initRemoteClassAliasAllRelated() : void 
    {
        valueObjects.Seat.initRemoteClassAliasSingleChild();
        valueObjects.Hand.initRemoteClassAliasSingleChild();
        valueObjects.Card.initRemoteClassAliasSingleChild();
        valueObjects.Player.initRemoteClassAliasSingleChild();
        valueObjects.Round.initRemoteClassAliasSingleChild();
        valueObjects.Pot.initRemoteClassAliasSingleChild();
        valueObjects.BettingRound.initRemoteClassAliasSingleChild();
    }

	model_internal var _dminternal_model : _TableEntityMetadata;

	/**
	 * properties
	 */
	private var _internal_replay : Boolean;
	private var _internal_gameOver : Boolean;
	private var _internal_notFoldedSeats : ArrayCollection;
	model_internal var _internal_notFoldedSeats_leaf:valueObjects.Seat;
	private var _internal_notBrokenSeats : ArrayCollection;
	model_internal var _internal_notBrokenSeats_leaf:valueObjects.Seat;
	private var _internal_round : valueObjects.Round;
	private var _internal_brokenSeats : ArrayCollection;
	model_internal var _internal_brokenSeats_leaf:valueObjects.Seat;
	private var _internal_numberOfRounds : int;
	private var _internal_takenSeats : ArrayCollection;
	model_internal var _internal_takenSeats_leaf:valueObjects.Seat;
	private var _internal_bigBlind : int;
	private var _internal_notAllInPlayers : ArrayCollection;
	model_internal var _internal_notAllInPlayers_leaf:valueObjects.Seat;
	private var _internal_seats : ArrayCollection;
	model_internal var _internal_seats_leaf:valueObjects.Seat;
	private var _internal_activePlayer : ArrayCollection;
	model_internal var _internal_activePlayer_leaf:valueObjects.Seat;
	private var _internal_smallBlind : int;
	private var _internal_dealerPos : int;

    private static var emptyArray:Array = new Array();

    /**
     * derived property cache initialization
     */  
    model_internal var _cacheInitialized_isValid:Boolean = false;   
    
	model_internal var _changeWatcherArray:Array = new Array();   

	public function _Super_Table() 
	{	
		_model = new _TableEntityMetadata(this);
	
		// Bind to own data properties for cache invalidation triggering  
       
	}

    /**
     * data property getters
     */
	[Bindable(event="propertyChange")] 
    public function get replay() : Boolean    
    {
            return _internal_replay;
    }    
	[Bindable(event="propertyChange")] 
    public function get gameOver() : Boolean    
    {
            return _internal_gameOver;
    }    
	[Bindable(event="propertyChange")] 
    public function get notFoldedSeats() : ArrayCollection    
    {
            return _internal_notFoldedSeats;
    }    
	[Bindable(event="propertyChange")] 
    public function get notBrokenSeats() : ArrayCollection    
    {
            return _internal_notBrokenSeats;
    }    
	[Bindable(event="propertyChange")] 
    public function get round() : valueObjects.Round    
    {
            return _internal_round;
    }    
	[Bindable(event="propertyChange")] 
    public function get brokenSeats() : ArrayCollection    
    {
            return _internal_brokenSeats;
    }    
	[Bindable(event="propertyChange")] 
    public function get numberOfRounds() : int    
    {
            return _internal_numberOfRounds;
    }    
	[Bindable(event="propertyChange")] 
    public function get takenSeats() : ArrayCollection    
    {
            return _internal_takenSeats;
    }    
	[Bindable(event="propertyChange")] 
    public function get bigBlind() : int    
    {
            return _internal_bigBlind;
    }    
	[Bindable(event="propertyChange")] 
    public function get notAllInPlayers() : ArrayCollection    
    {
            return _internal_notAllInPlayers;
    }    
	[Bindable(event="propertyChange")] 
    public function get seats() : ArrayCollection    
    {
            return _internal_seats;
    }    
	[Bindable(event="propertyChange")] 
    public function get activePlayer() : ArrayCollection    
    {
            return _internal_activePlayer;
    }    
	[Bindable(event="propertyChange")] 
    public function get smallBlind() : int    
    {
            return _internal_smallBlind;
    }    
	[Bindable(event="propertyChange")] 
    public function get dealerPos() : int    
    {
            return _internal_dealerPos;
    }    

    /**
     * data property setters
     */      
    public function set replay(value:Boolean) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:Boolean = _internal_replay;               
        if (oldValue !== value)
        {
            _internal_replay = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "replay", oldValue, _internal_replay));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set gameOver(value:Boolean) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:Boolean = _internal_gameOver;               
        if (oldValue !== value)
        {
            _internal_gameOver = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "gameOver", oldValue, _internal_gameOver));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set notFoldedSeats(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_notFoldedSeats == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_notFoldedSeats;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_notFoldedSeats = value;
            }
            else if (value is Array)
            {
                _internal_notFoldedSeats = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of notFoldedSeats must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "notFoldedSeats", oldValue, _internal_notFoldedSeats));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set notBrokenSeats(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_notBrokenSeats == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_notBrokenSeats;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_notBrokenSeats = value;
            }
            else if (value is Array)
            {
                _internal_notBrokenSeats = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of notBrokenSeats must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "notBrokenSeats", oldValue, _internal_notBrokenSeats));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set round(value:valueObjects.Round) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_round == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:valueObjects.Round = _internal_round;               
        if (oldValue !== value)
        {
            _internal_round = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "round", oldValue, _internal_round));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set brokenSeats(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_brokenSeats == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_brokenSeats;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_brokenSeats = value;
            }
            else if (value is Array)
            {
                _internal_brokenSeats = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of brokenSeats must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "brokenSeats", oldValue, _internal_brokenSeats));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set numberOfRounds(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_numberOfRounds;               
        if (oldValue !== value)
        {
            _internal_numberOfRounds = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "numberOfRounds", oldValue, _internal_numberOfRounds));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set takenSeats(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_takenSeats == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_takenSeats;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_takenSeats = value;
            }
            else if (value is Array)
            {
                _internal_takenSeats = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of takenSeats must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "takenSeats", oldValue, _internal_takenSeats));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set bigBlind(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_bigBlind;               
        if (oldValue !== value)
        {
            _internal_bigBlind = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "bigBlind", oldValue, _internal_bigBlind));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set notAllInPlayers(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_notAllInPlayers == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_notAllInPlayers;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_notAllInPlayers = value;
            }
            else if (value is Array)
            {
                _internal_notAllInPlayers = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of notAllInPlayers must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "notAllInPlayers", oldValue, _internal_notAllInPlayers));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set seats(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_seats == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_seats;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_seats = value;
            }
            else if (value is Array)
            {
                _internal_seats = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of seats must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "seats", oldValue, _internal_seats));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set activePlayer(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_activePlayer == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_activePlayer;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_activePlayer = value;
            }
            else if (value is Array)
            {
                _internal_activePlayer = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of activePlayer must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "activePlayer", oldValue, _internal_activePlayer));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set smallBlind(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_smallBlind;               
        if (oldValue !== value)
        {
            _internal_smallBlind = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "smallBlind", oldValue, _internal_smallBlind));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set dealerPos(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_dealerPos;               
        if (oldValue !== value)
        {
            _internal_dealerPos = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "dealerPos", oldValue, _internal_dealerPos));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    

    /**
     * data property setter listeners
     */   

   model_internal function setterListenerAnyConstraint(value:flash.events.Event):void
   {
        if (model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }        
   }   

    /**
     * valid related derived properties
     */
    model_internal var _isValid : Boolean;
    model_internal var _invalidConstraints:Array = new Array();
    model_internal var _validationFailureMessages:Array = new Array();

    /**
     * derived property calculators
     */

    /**
     * isValid calculator
     */
    model_internal function calculateIsValid():Boolean
    {
        var violatedConsts:Array = new Array();    
        var validationFailureMessages:Array = new Array();    

		if (_model.isNotFoldedSeatsAvailable && _internal_notFoldedSeats == null)
		{
			violatedConsts.push("notFoldedSeatsIsRequired");
			validationFailureMessages.push("notFoldedSeats is required");
		}
		if (_model.isNotBrokenSeatsAvailable && _internal_notBrokenSeats == null)
		{
			violatedConsts.push("notBrokenSeatsIsRequired");
			validationFailureMessages.push("notBrokenSeats is required");
		}
		if (_model.isRoundAvailable && _internal_round == null)
		{
			violatedConsts.push("roundIsRequired");
			validationFailureMessages.push("round is required");
		}
		if (_model.isBrokenSeatsAvailable && _internal_brokenSeats == null)
		{
			violatedConsts.push("brokenSeatsIsRequired");
			validationFailureMessages.push("brokenSeats is required");
		}
		if (_model.isTakenSeatsAvailable && _internal_takenSeats == null)
		{
			violatedConsts.push("takenSeatsIsRequired");
			validationFailureMessages.push("takenSeats is required");
		}
		if (_model.isNotAllInPlayersAvailable && _internal_notAllInPlayers == null)
		{
			violatedConsts.push("notAllInPlayersIsRequired");
			validationFailureMessages.push("notAllInPlayers is required");
		}
		if (_model.isSeatsAvailable && _internal_seats == null)
		{
			violatedConsts.push("seatsIsRequired");
			validationFailureMessages.push("seats is required");
		}
		if (_model.isActivePlayerAvailable && _internal_activePlayer == null)
		{
			violatedConsts.push("activePlayerIsRequired");
			validationFailureMessages.push("activePlayer is required");
		}

		var styleValidity:Boolean = true;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
    
        model_internal::_cacheInitialized_isValid = true;
        model_internal::invalidConstraints_der = violatedConsts;
        model_internal::validationFailureMessages_der = validationFailureMessages;
        return violatedConsts.length == 0 && styleValidity;
    }  

    /**
     * derived property setters
     */

    model_internal function set isValid_der(value:Boolean) : void
    {
       	var oldValue:Boolean = model_internal::_isValid;               
        if (oldValue !== value)
        {
        	model_internal::_isValid = value;
        	_model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
        }        
    }

    /**
     * derived property getters
     */

    [Transient] 
	[Bindable(event="propertyChange")] 
    public function get _model() : _TableEntityMetadata
    {
		return model_internal::_dminternal_model;              
    }	
    
    public function set _model(value : _TableEntityMetadata) : void       
    {
    	var oldValue : _TableEntityMetadata = model_internal::_dminternal_model;               
        if (oldValue !== value)
        {
        	model_internal::_dminternal_model = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
        }     
    }      

    /**
     * methods
     */  


    /**
     *  services
     */                  
     private var _managingService:com.adobe.fiber.services.IFiberManagingService;
    
     public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
     {
         _managingService = managingService;
     }                      
     
    model_internal function set invalidConstraints_der(value:Array) : void
    {  
     	var oldValue:Array = model_internal::_invalidConstraints;
     	// avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_invalidConstraints = value;   
			_model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);   
        }     	             
    }             
    
     model_internal function set validationFailureMessages_der(value:Array) : void
    {  
     	var oldValue:Array = model_internal::_validationFailureMessages;
     	// avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_validationFailureMessages = value;   
			_model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);   
        }     	             
    }        
     
     // Individual isAvailable functions     
	// fields, getters, and setters for primitive representations of complex id properties

}

}
